import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';

/**
 * 用户实体
 */
@Entity({ name: 'users', comment: '用户表' })
export class User {
  @ApiProperty({ description: '用户ID' })
  @PrimaryGeneratedColumn({ comment: '用户ID' })
  id: number;

  @ApiProperty({ description: '用户名' })
  @Column({ 
    unique: true, 
    length: 50,
    comment: '用户名，唯一标识' 
  })
  username: string;

  @ApiProperty({ description: '邮箱' })
  @Column({ 
    unique: true, 
    length: 100,
    comment: '邮箱地址，唯一标识' 
  })
  email: string;

  @ApiProperty({ description: '密码' })
  @Column({ 
    length: 255,
    comment: '密码哈希值' 
  })
  password: string;

  @ApiProperty({ description: '昵称' })
  @Column({ 
    length: 50, 
    nullable: true,
    comment: '用户昵称' 
  })
  nickname?: string;

  @ApiProperty({ description: '头像URL' })
  @Column({ 
    nullable: true,
    comment: '用户头像URL地址' 
  })
  avatar?: string;

  @ApiProperty({ description: '是否激活' })
  @Column({ 
    default: true,
    comment: '用户账号是否激活' 
  })
  isActive: boolean;

  @ApiProperty({ description: '创建时间' })
  @CreateDateColumn({ comment: '记录创建时间' })
  createdAt: Date;

  @ApiProperty({ description: '更新时间' })
  @UpdateDateColumn({ comment: '记录更新时间' })
  updatedAt: Date;
}